<?php

class Validator {

	private $multi_message;
	public function __construct(){ $this->multi_message = new MultiMessage(); }

	public function HasPassed(){ return $this->multi_message->GetSeverity() <= Message::INFO; }
	public function AsMessage(){ return $this->multi_message; }

	public function Check($condition,$message){
		if (!$condition)
			$this->multi_message[] =  $message instanceof Message ? $message : new WarningMessage($message) ;
		return $condition;
	}

	public function CheckMandatory($that,$message=null){
		if (is_null($that))
			return $this->Check(false , $message != null ? $message : Lemma::ErrorMandatoryField());
		if (is_string($that))
			return $this->Check(trim($that) != '', $message != null ? $message : Lemma::ErrorMandatoryField() );
		return true;
	}

}


?>
